#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
void solve()
{
    ll n0, n, base;
    cin >> n >> base;
    n0 = n;
    stack<char> ans;
    int i = 0;
    while (n)
    {
        if (n % base == 0)
        {
            ans.push('0');
            n /= base;
        }
        else if (n % base > 0)
        {
            if (n % base <= 9)
                ans.push(n % base + '0');
            else
                ans.push(n % base - 10 + 'A');
            n /= base;
        }
        else
        {
            if (n % base - base <= 9)
                ans.push(n % base - base + '0');
            else
                ans.push(n % base - base - 10 + 'A');
            n = n / base + 1;
        }
    }
    cout << n0 << '=';
    if (ans.empty())
        cout << 0;
    else
        while (!ans.empty())
        {
            cout << ans.top();
            ans.pop();
        }
    cout << "(base" << base << ')';
}
int main()
{
    solve();
    return 0;
}
